﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KP_CommonLibrary.KP_DataAccess;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using KP_CommonLibrary.KP_ObjectReferences;
using System.Data;

namespace KEEPER_BRR_13dotNET.DataAccess
{
    public class DAL_KPHoSo : KP_DALListBase
    {
        public DAL_KPHoSo()
            : base("tblHoSo")
        {
        }

        public void XoaTruocKhiCapNhat(SqlTransaction tran,string stt_rec)
        {
            SqlHelper.ExecuteNonQuery(tran, "kp_HoSoXoaTruocKhiCapNhat", new object[] { stt_rec });
        }
        public DataRow SelectBySttRec(string sttRec)
        {
          DataTable tblData=  SqlHelper.ExecuteDataTable(KP_OCnnSql.Cnn_String, "kp_HoSoSelectBySttRec", new object[] { sttRec });
          return tblData.Rows.Count > 0 ? tblData.Rows[0] : null;
        }
        public void ChuyenViTriHoSo(SqlTransaction tran,string sttRec, string maVtri)
        {
            string sql="Update tblHoSo set Ma_Vt='"+maVtri+"' WHERE Stt_Rec='"+sttRec+"'";
            SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql);

        }
        public DataTable SelectByMaTtAndMaVt(string maTt, string maVt)
        {
            string sql = "Select * from vHoSo where Ma_Tt='" + maTt + "' And Ma_Vt='" + maVt + "'";
            return SqlHelper.ExecuteDataTable(KP_OCnnSql.Cnn_String, CommandType.Text, sql);

        }

        public DataTable FindDangKyKdByKeyword(string keyWord, int trangthai1, int trangthai2, string maVtri)
        {
            return SqlHelper.ExecuteDataTable(KP_OCnnSql.Cnn_String, "[kp_HoSoTimKiemTheoTuKhoa]", keyWord, trangthai1, trangthai2, maVtri, false);
        }
        public void DuyetHoSo(string sttRec, int ma_tt, int nextMa_Tt, string lydo, string user0, string client0, int type)
        {
            int i = SqlHelper.ExecuteNonQuery(KP_OCnnSql.Cnn_String, "kp_DuyetHoSo", sttRec, ma_tt, nextMa_Tt, lydo, user0, client0, type);
        }
        public void KetThucDuyetHs(string sttRec, int ma_tt, int nextMa_Tt, string lydo, string user0, string client0)
        {
            int i = SqlHelper.ExecuteNonQuery(KP_OCnnSql.Cnn_String, "kp_DangKyKDKetThucDuyetHS", sttRec, ma_tt, nextMa_Tt, lydo, user0, client0);
        }

        public void TraHoSo(string sttRec, string user0, string client0)
        {
            int i = SqlHelper.ExecuteNonQuery(KP_OCnnSql.Cnn_String, "KP_DangKyKDTraHoSo", sttRec, user0, client0);
        }

    }
}
